Delivery of video content is available through a mobile device or other living room-connected devices, such as personal computers or set-top boxes. Different protocols may be used to stream the video. One protocol is hypertext transfer protocol (HTTP) live streaming (HLS). The HLS protocol delivers video over HTTP via a playlist of small segments that are made available in a variety of bitrates typically from a content delivery network (CDN). This allows a media player to switch bitrates on a segment-by-segment basis. The switching helps compensate for network bandwidth variances that may occur during playback of the video.
To allow a media player to switch between bitrates, the segments for each bitrate must be aligned. That is, if the media player switches from a first stream of a first bitrate to a second stream of a second bitrate, a segment in the second stream must be aligned at the same time as a segment of the first stream that was about to be played. For example, the media player may play segment #9 from the first stream at the first bitrate. If the media player is about to play a segment #10 at the first bitrate, but switches to the second stream at the second bitrate, segment #10 from the stream at the second bitrate should start at the same time as segment #10 of the first stream at the first bitrate. If the segments are not aligned, then the video would become choppy as some video might be skipped because the time that segment #9 ended would not be continuous with the time that segment #10 of the second stream starts.
To force the alignment between multiple bitrate encodings, an encoder would encode a video file at a first bitrate. A user would program where an encoder inserts keyframes. For example, the user may choose that a keyframe is inserted every 60 seconds. Then, when the encoder encodes the video file, the encoder inserts a keyframe every 60 seconds. When the video is encoded at the second bitrate, the encoder inserts keyframes at the same 60-second intervals. This process continues for as many numbers of bitrates that are encoded. By forcing the keyframes to be inserted at the same times, each encoding at a different bitrate would have the keyframes that are aligned. This allows all the streams to be segmented at keyframes that reside in the same position. For example, each segment may be 60 seconds long and is split at a keyframe. However, by forcing the keyframes to be inserted every 60 seconds, the keyframes may be inserted at undesirable points. For example, it may be desirable to have the keyframe boundaries at points where there is a scene change or a discontinuity in motion. This allows frames within the segment to leverage the information within the segment for motion estimation and compensation more efficiently. However, if a keyframe boundary occurs where continuous motion is occurring, then the encoding becomes less efficient because motion information that is in a next segment cannot be leveraged because only motion information in the present segment can be used in motion estimation and compensation.